﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace IESN.MyControl
{
    public partial class DataGridForKeyProcess : DataGrid
    {
        private bool RetValue = true;

        //public event KeyprocessEventHandler Keyprocess;
        public event KeyprocessEventHandler KeyprocessEvent;

        protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
        {
            //bool flag;
            bool flag = true;
            int num = 0x100;
            int num2 = 260;
            if (!((msg.Msg == num) | (msg.Msg == num2)))
            {
                return flag;
            }
            if ((((((((keyData == Keys.Left) | (keyData == Keys.Right)) | (keyData == Keys.Up)) | (keyData == Keys.Down)) | (keyData == Keys.Prior)) | (keyData == Keys.Next)) | (keyData == Keys.Home)) | (keyData == Keys.End))
            {
                if (this.KeyprocessEvent != null)
                {
                    this.KeyprocessEvent(keyData);
                }
                return this.RetValue;
            }
            if (keyData == Keys.Escape)
            {
                this.RetValue = !this.RetValue;
                if (this.KeyprocessEvent != null)
                {
                    this.KeyprocessEvent(keyData);
                }
                return true;
            }
            if (keyData != Keys.Return)
            {
                return flag;
            }
            if (this.KeyprocessEvent != null)
            {
                this.KeyprocessEvent(keyData);
            }
            SendKeys.Send("{Tab}");
            return true;
        }

        public delegate void KeyprocessEventHandler(Keys keyData);
    }
}
